home *** CD-ROM | disk | FTP | other *** search
/ United Public Domain Gold 2 / United Public Domain Gold 2.iso / utilities / pu374.dms / pu374.adf / AlertTimer / AlertTimer.asm < prev    next >
Assembly Source File  |  1993-01-10  |  3KB  |  86 lines

  1. *************************************
  2. * AlertTimer - alert timing utility *
  3. *        (C) SinSoft 1993           *
  4. *************************************
  5.  
  6. ;Include files not needed to assembly this program
  7. ;Use almost any 68K assembler
  8.  
  9.     move.l    4.w,a6            ;get execbase
  10.     cmpi.w    #39,$14(a6)        ;LIB_VERSION compared
  11.     bcs.s    failure            ;we aren't running under 3.0
  12.     moveq    #4,d0            ;dos.library tag number
  13.     jsr    -810(a6)        ;OpenTaggedLibrary function called
  14.     move.l    a6,a5            ;execbase stored
  15.     move.l    d0,a6            ;dos will be used
  16.     tst.l    d0
  17.     bne.s    dosok            ;library opened OK
  18. failure    moveq    #20,d0            ;return code
  19.     rts                ;bye
  20. dosok    clr.l    -(sp)
  21.     clr.l    -(sp)            ;workspace on the stack made
  22.     lea    intemp(pc),a0        ;input template addr
  23.     move.l    a0,d1            ;to be pc-relative
  24.     move.l    sp,d2            ;our space
  25.     clr.l    d3
  26.     jsr    -$31e(a6)        ;ReadArgs function called
  27.     move.l    d0,d7            ;remeber this to free args later
  28.     bne.s    ok            ;Arguments ok
  29.     jsr    -132(a6)        ;IoErr function called - error determined
  30.     move.l    d0,d1            ;error code
  31.     move.l    d3,d2
  32.     jsr    -$1da(a6)        ;PrintFault function called
  33.     bra.s    clodos            ;we can't do anything more
  34. ok    lea    primes(pc),a1        ;address of primary message
  35.     move.l    a1,d1            ;to be PC-relative
  36.     jsr    -$3ba(a6)        ;Printf function called
  37.     lea    $20e(a5),a3        ;address of timing variable
  38.     clr.w    d6
  39.     move.b    $212(a5),d6        ;VBlank frequency as a word fetched
  40.     tst.l    (sp)
  41.     beq.s    nonum            ;timing value not specified
  42.     move.l    (sp),a1            ;Address of the value
  43.     move.l    (a1),d0            ;Value itself
  44.     move.l    d0,(sp)            ;stored for the message
  45.     mulu    d6,d0            ;multiplied by VBlank
  46.     move.l    d0,(a3)            ;and stored to execbase for use by Alert()
  47.     
  48. printit    lea    curmes(pc),a1        ;message address
  49. print2    move.l    a1,d1            ;to be pc-relative
  50.     move.l    sp,d2            ;arguments
  51.     jsr    -$3ba(a6)        ;Printf function called
  52.  
  53.     move.l    d7,d1            ;Argument address
  54.     jsr    -$35a(a6)        ;FreeArgs function called
  55.  
  56. clodos    move.l    a6,a1            ;dosbase as an argument to CloseLibrary()
  57.     move.l    a5,a6            ;execbase reactivated
  58.     jsr    -414(a6)        ;CloseLibrary function called
  59.     moveq    #0,d0
  60.     lea    8(sp),sp        ;space discarded
  61.     rts
  62.  
  63. nonum    tst.l    4(sp)
  64.     beq.s    query            ;OFF switch unspecified
  65.     moveq    #-1,d0
  66.     move.l    d0,(a3)            ;store -1 as an OFF value
  67. turnof    lea    curmes2(pc),a1        ;message address
  68.     bra.s    print2
  69.     
  70. query    move.l    (a3),d0            ;get current value
  71.     addq.l    #1,d0
  72.     beq.s    turnof            ;it is -1 - tell it
  73.     subq.l    #1,d0
  74.     divu    d6,d0            ;convert to seconds
  75.     andi.l    #$ffff,d0        ;ignore remainder
  76.     move.l    d0,(sp)            ;store the value
  77.     bra.s    printit
  78.  
  79. intemp    dc.b    'TIMING/N,OFF/S',0
  80. primes    dc.b    'Alert timing is ',0
  81. curmes    dc.b    'set to %ld seconds.',10,0
  82. curmes2    dc.b    'turned off.',10,0
  83.     dc.b    '$VER: alerttimer 39.1 (10.1.93)',0
  84.  
  85.     end
  86.